package com.example.pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class HomePage extends InternalPage{

    @FindBy(xpath = "//div[@class='button']//a[@href='./?go=add']")
    public WebElement addMovieLink;

    @FindBy(css = "div.title")
    public WebElement movieLink;

    public AddMoviePage goToAddMoviePage() {
        addMovieLink.click();
        return MyPageFactory.getPage(driver, AddMoviePage.class);
    }

    public MoviePage goToMovie() {
        movieLink.click();
        return MyPageFactory.getPage(driver, MoviePage.class);
    }

    public boolean isOnThisPage() {
        return addMovieLink.isDisplayed();
    }

    @Override
    void tryToOpen() {
        MyPageFactory.getPage(driver, InternalPage.class).goToHomePage();
    }

}
